package com.xyyl.patient.controller;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.xyyl.patient.core.controller.BaseController;
import com.xyyl.patient.core.support.Pager;
import com.xyyl.patient.core.util.ResponseBodyResult;
import com.xyyl.patient.entity.article.BannerEntity;
import com.xyyl.patient.service.article.BannerService;

/**
 * @projectName:xyyl-oms-server
 * @ClassName: Banner
 * @Description:Banner
 * @author wqs
 * @date 2018-01-03 11:26:30
 */

@RestController
@RequestMapping("/banner")
public class BannerController extends BaseController {

	private Logger logger = Logger.getLogger(getClass());

	@Autowired
	private BannerService bannerService;

	/**
	 * 列表
	 */
	@RequestMapping(value = "/findBanner", method = RequestMethod.GET)
	public JSONObject list() {

		logger.info("----列表查询----");

		try {
			Pager pager = super.initPage();
			List<BannerEntity> bannerList = bannerService.queryList(pager);
			return ResponseBodyResult.success(bannerList);

		} catch (Exception e) {
			return ResponseBodyResult.error("查询失败", e);
		}

	}

	/**
	 * 文章详情页
	 * 
	 * @param articleId
	 * @return
	 */
	@RequestMapping(value = "/bannerDetail", method = RequestMethod.GET)
	public JSONObject doctorDetail(@RequestParam Integer bannerId) {
		try {
			BannerEntity bannerEntity = bannerService.getByBannerId(bannerId);
			return ResponseBodyResult.success(bannerEntity);
		} catch (Exception e) {
			return ResponseBodyResult.error("查询失败!", e);

		}

	}
}
